function liga(pagina,div,param){
	var x = Math.random()*1000;
	x = Math.round(x);
	document.getElementById(div).style.display = "block";
	document.getElementById(div).innerHTML = "<center><img src='../images/aero_busy_xl.gif' border='0'></img>&nbsp;<strong>Cargando...</strong></center>";
	var url = pagina+"&x="+x;
	if (param) url = url+"&campo="+param;
	alert(url);
	new Ajax.Updater(div, url);
}

function busqueda(pagina,div,notcampos){
	//alert(pagina);
	var v = document.forma;
	var x = Math.random()*1000;
	x = Math.round(x);
	document.getElementById(div).style.display = "block";
	document.getElementById(div).innerHTML = "<center><img src='../images/aero_busy_xl.gif' border='0'></img>&nbsp;<strong>Cargando...</strong></center>";
	var dir3 = pagina+"?x="+x;
	if (!notcampos){
		for(i=0;i<10;i++){
			if(v.elements[i]){
				nombre = v.elements[i].name;
				if(v.elements[i].type=="checkbox"){
					if(v.elements[i].checked == true)
						valor = 2;
					else
						valor = 1;
				}
				else{
					valor = v.elements[i].value;
				}
				dir3 += "&"+nombre+"="+valor;
			}
		}
	}
	
	//alert(dir3);
	new Ajax.Updater(div, dir3);
}

//Ceros y no vacios  -- 05:24 -- Macz
function ceros(objeto)
	{
		if (objeto.value == "" ){objeto.value = 0;}
	}

function busqueda2(pagina,div,param){
	var v = document.forma;
	var x = Math.random()*1000;
	x = Math.round(x);
	document.getElementById(div).style.display = "block";
	document.getElementById(div).innerHTML = "<center><img src='../images/aero_busy_xl.gif' border='0'></img>&nbsp;<strong>Cargando...</strong></center>";
	var dir3 = pagina+"?tipo="+param+"&x="+x;
	for(i=0;i<v.elements.length;i++){
		if(v.elements[i]){
			nombre = v.elements[i].name;
			valor = v.elements[i].value;
			dir3 += "&"+nombre+"="+valor;
		}
	}
	//alert(dir3);
	if(param==1){
		window.location=dir3;
		
	}else{
		new Ajax.Updater(div, dir3);
	}
}


function cambiaunidad(){
	var v = document.forma;
	var x = Math.random()*1000;
	x = Math.round(x);
	if(v.delegacion1){
		$("transp_u").style.display = "block";
		$("transp_u").innerHTML = "<img src='../images/ajax-loader.gif' border='0'></img>&nbsp;<strong>Cargando...</strong>";
		var dir1 = "../combos.php?cual=delegacion&del="+v.delegacion1.value+"&x="+x;
		new Ajax.Updater("unidades", dir1);
	}
	else{
		$("transp_u").innerHTML = "<p class='datos'>ERROR</p>";
	}
}

function acceptNum(evt){ 
	var nav = navigator.appName; 
	var num = nav.indexOf("Explorer");
	var key = (num == -1)? evt.which : evt.keyCode;
	return (key <= 13 || key == 46 || (key >= 48 && key <= 57));
}

function detalle(idp,sal){
	var x = Math.random()*1000;
	x = Math.round(x);
	var v = document.forma;
	var dir1 = "detalle_deteccion.php?idp="+idp+"&x="+x;
	var obj1 = eval("document.images['signo"+idp+"']");
	var cad = obj1.src;
	for(i=0;i<10;i++){
		if(v.elements[i]){
			nombre = v.elements[i].name;
			if(v.elements[i].type=="checkbox"){
				if(v.elements[i].checked == true )
					valor = 2;
				else
					valor = 1;
			}
			else{
				valor = v.elements[i].value;
			}
			dir1 += "&"+nombre+"="+valor;
		}
	}
	if(cad.match("mas.gif") || sal){
		obj1.src = "../images/menos.gif";
	}
	else{
		obj1.src = "../images/mas.gif";
		var dir1 = "../null.php";
	}
	new Ajax.Updater("detalle"+idp, dir1);
}

function vertodo(){
	var sal = 0;
	if($("msj1").innerHTML=='VER TODOS LOS DETALLES'){
		$("msj1").innerHTML="OCULTAR TODOS LOS DETALLES";
		sal = 1;
	}
	else{
		$("msj1").innerHTML="VER TODOS LOS DETALLES";
		sal = 0;
	}
	for(var i=1; i<36; i++){
		detalle(i,sal);
	}
}

function masfil(div,val,cual){
	var v = document.forma;
	var x = Math.random()*1000;
	x = Math.round(x);
	
	$(div).style.display = "block";
	$(div).innerHTML = "<p class='datos'>CARGANDO...<br><img src='../images/barra_loader.gif' border='0'></img></p>";
	
	var dir = "usos_multiples.php?x="+x+"&concentrado="+val+"&cual="+cual;
	//alert(dir);
	new Ajax.Updater(div,dir);
}

function cambio_srubro(){
	var v = document.forma;
	var x = Math.random()*1000;
	x = Math.round(x);
	document.getElementById("subconcepto").style.display = "block";
	document.getElementById("subconcepto").innerHTML = "<img src='../images/ajax-loader.gif' border='0'></img>&nbsp;<strong>Cargando...</strong>";
	var dir1 = "../combos.php?cual=plansrubro1&rubro="+v.concepto.value+"&x="+x;
	new Ajax.Updater("subconcepto", dir1,{evalScripts:true});
}